#include <sysdep.h>
#include <utils.h>

size_t strnlen(const char *s, size_t count)
{
	const char *sc;

	for (sc = s; count-- && *sc != '\0'; ++sc)
		/* nothing */;
	return sc - s;
}

char *strndup(const char *s1, size_t n)
{
	char *s;
	
	n = strnlen(s1,n);
	
	if ((s = malloc(n + 1)) != NULL) {
		memcpy(s, s1, n);
		s[n] = 0;
	}
	return s;
}

void panic(const char *s)
{
	if (s)
		printf("%s\r\n", s);
	for (;;)
		;
}

